import time

from selenium.webdriver.common.alert import Alert
from selenium.webdriver.common.by import By
from pages.basepage import Basepage



class MSG(Basepage):
     wdzh=(By.LINK_TEXT,'我的账户')
     wdly=(By.LINK_TEXT,'我的留言')
     zt=(By.NAME,'msg_title')
     nr = (By.NAME, 'msg_content')
     wj = (By.NAME, 'message_img')
     tj=(By.XPATH,'//input[@type="submit" and @class="bnt_bonus"]')
     sc=(By.XPATH,'//*[@class="userCenterBox boxCenterList clearfix"]//a[1]')
     jl=(By.CSS_SELECTOR, '#pager>.f_l>b')
     def liuyan(self,ZT='差评', NR='照骗', WJ=''):
          self.bf = self.getEleTxt(self.findELe(self.jl))
          self.dlchlick(self.findELe(self.wdzh))
          # self.dlchlick(self.findELe(self.wdzh))
          # d.find_element(*self.wdzh).click()
          time.sleep(2)
          self.dlchlick(self.findELe(self.wdly))
          # d.find_element(*self.wdly).click()
          time.sleep(2)
          self.inputText(self.findELe(self.zt), ZT)
          # d.find_element(*self.zt).send_keys(ZT)
          time.sleep(2)
          self.inputText(self.findELe(self.nr),NR)
          # d.find_element(*self.nr).send_keys(NR)
          time.sleep(2)
          self.inputText(self.findELe(self.wj),WJ)
          # d.find_element(*self.wj).send_keys(WJ)
          time.sleep(2)
          self.dlchlick(self.findELe(self.tj))
          # d.find_element(*self.tj).click()
          time.sleep(5)
     def shanchu(self):
          self.dlchlick(self.findELe(self.wdzh))
          self.dlchlick(self.findELe(self.wdly))
          self.dlchlick(self.findELe(self.sc))
          tc=Alert(self.d)
          tc.accept()
     def addok(self):
          # xz=self.getEleTxt(self.jl)
          xz = self.getEleTxt(self.findELe(self.jl))
          return self.bf,xz
     def addNone(self):
          return self.getAlrettxt()

if __name__ =='__main__':
     from pages.indexpages import IndexPage
     ys = IndexPage()
     mp = ys.go_to_myInfopage().clickwdly()
     mp.addok()
